12. Controlling Components Using Code
Controlling Components Using Code
Video Addendum
Tip: To more easily see that the seagulls have different colors, try changing the color assignment to use the
Random.ColorHSVmethod to generate random colors rather than only differnt shades of gray:
// objectRenderer.material.color = Color.white * Random.value;
objectRenderer.material.color = Random.ColorHSV();
Recommended Reading
- Unity Scripting API: GameObject.GetComponent
- Unity Scripting API: GameObject.GetComponentInChildren
Additional Reading
- Unity Manual: Controlling GameObjects using components
- Unity Manual: Random.ColorHSV